import Vue from 'vue'
import App from './App.vue'
import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'
import router from './router'
import store from './store'
import axios from 'axios'
import { Indicator } from 'mint-ui'
import qs from 'qs';
Vue.use(MintUI)

import Vant from 'vant';
import 'vant/lib/index.css';
import 'animate.css';
Vue.use(Vant);



Vue.config.productionTip = false
Vue.prototype.$axios = axios
// axios.defaults.baseURL = 'https://ele-interface.herokuapp.com/api/';
// 请求拦截
axios.interceptors.request.use(
  config => {
    // if (config.method == 'post') {
    //   config.data = qs.stringify(config.data);
    // }

    // 加载动画
    Indicator.open();
    return config;
  },
  error => {
    return Promise.reject(error);
  }
);

//response拦截器
axios.interceptors.response.use(
  (res) => {
    Indicator.close()
    return res
  },
  (error) => {
    Indicator.close()
    return Promise.reject(error.response.data) // 返回错误信息
  }
)

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app')
